﻿<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="Users.aspx.cs" Inherits="KPIS.GERP.SECURITY.App_UI.Forms.Users" %>

<asp:Content 
    ID="Content1" 
    runat="server" 
    contentplaceholderid="ContentPlaceHolder1">  
   
    <link rel="stylesheet" type="text/css" runat="server" href="<%$ Resources:Resource, cssFileName %>" />
    <telerik:radcodeblock ID="RadCodeBlock2" runat="server">

        <script type="text/javascript">
            function onTextChange(sender) {
                if (sender.get_value() == "") {
                    sender.set_text("");
                }
            }

        </script>

    </telerik:radcodeblock>
    <telerik:radajaxmanager ID="RadAjaxManager1" runat="server" >
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="PanelFilter">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelFilter" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="PanelUserRole" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="PanelFilter" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="PanelUserRole" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="PanelUserRole">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelFilter" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="PanelUserRole" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelFilter" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="PanelUserRole" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:radajaxmanager>
    <telerik:radajaxloadingpanel ID="RadAjaxLoadingPanel1" runat="server" 
        Height="100%" Width="75px" Transparency="50">
        <table style="height: 100%; width: 100%" border="0">
            <tr>
                <td width="100%" align="center" valign="middle">
                    <img alt="Loading..." 
                        src="../Images/Buttons/loading.gif" 
                        style="border: 0px;" />
                </td>
            </tr>
        </table>
    </telerik:radajaxloadingpanel>
    <telerik:radwindowmanager ID="RadWindowManager1" runat="server">
        <Windows>
            <telerik:RadWindow 
                id="ProjectDtls" 
                runat="server"
                showcontentduringload="false"
                VisibleStatusbar="false"
                title=""
                width="800px"
                Height="600px"        
                Modal="true"
                behaviors="Close">
            </telerik:RadWindow>
        </Windows>
    </telerik:radwindowmanager>

    <div class="moduleDivSlim1000" >
    <div class="moduleDivBottom1000">
        <table >
         <tr>
            <td align="right" style="font-weight: bold; font-size: small">ประเภทบุคลากร :</td>
            <td align="left" >
                <asp:RadioButtonList ID="rdoEmployeeType" runat="server" 
                    RepeatDirection="Horizontal" AutoPostBack="True" 
                    onselectedindexchanged="rdoEmployeeType_SelectedIndexChanged"
                    DataValueField="emp_type_seq" DataTextField="emp_type_name" >
                </asp:RadioButtonList>
            </td>
        </tr>
        </table>
    </div>
    </div> 
    <div class="moduleDivSlim1000x450"  style="margin-top: 0px; ">
        <div class="moduleDivBottom1000"> 
            <asp:Panel ID="PanelFilter" runat="server" Width="100%" ScrollBars="Auto">           
                <table align="center" width="100%">
                     <tr>
                        <td class="TextHeader">
                            <table border="0" width="100%">
                                <tr>
                                    <td><asp:Label ID="lblHeader" runat="server" /></td>
                                    <td align="right">
                                        <a runat="server" href="Users.aspx?Export=true" style="font-size:small; font-family:sans-serif;">ออกจดหมายเวียนแจ้งสิทธิ์การใช้งาน</a>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <telerik:RadGrid ID="RadGrid1" runat="server" 
                                AllowAutomaticDeletes="True" 
                                AllowFilteringByColumn="True" AllowMultiRowEdit="True" 
                                AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True" 
                                AutoGenerateColumns="False" EnableAJAX="True" 
                                EnableAJAXLoadingTemplate="True" 
                                GridLines="None" 
                                OnItemCommand="RadGrid1_ItemCommand"  
                                Width="100%" PageSize="100" >
                                    <MasterTableView AllowMultiColumnSorting="True" 
                                    CellSpacing="-1" 
                                    ClientDataKeyNames="user_seq" 
                                    CommandItemDisplay="Top" 
                                    DataKeyNames="user_seq" 
                                    InsertItemPageIndexAction="ShowItemOnCurrentPage" 
                                    NoMasterRecordsText="&lt; ไม่มีข้อมูล &gt;">
                                    <CommandItemTemplate>
                                        <table width="100%">
                                            <tr>
                                                <td>
                                                    <asp:LinkButton ID="cmdAddNew" runat="server" CausesValidation="False" 
                                                        CommandName="InitInsert" 
                                                            Visible="<%# !RadGrid1.MasterTableView.IsItemInserted && RadGrid1.EditIndexes.Count <= 0 %>" 
                                                        > <img style="border:0px;vertical-align:middle;" alt=""                                    
                                            src="../Images/Buttons/AddRecord.gif" />เพิ่มผู้ใช้งานระบบ</asp:LinkButton>
                                        &nbsp;&nbsp;
                                                </td>
                                                <td align="right">
                                                </td>
                                            </tr>
                                        </table>
                                    </CommandItemTemplate>
                                    <RowIndicatorColumn>
                                        <HeaderStyle Width="20px" />
                                    </RowIndicatorColumn>
                                    <ExpandCollapseColumn>
                                        <HeaderStyle Width="20px" />
                                    </ExpandCollapseColumn>
                                    <Columns>
                                        <telerik:GridEditCommandColumn
                                            ButtonType="ImageButton" 
                                            EditText="คลิกเพื่อแก้ไขรายการ" 
                                            ItemStyle-Width="15">
                                            <ItemStyle HorizontalAlign="Center" />
                                            <HeaderStyle Width="15px"></HeaderStyle>
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridButtonColumn 
                                            ButtonType="ImageButton" 
                                            CommandName="Delete" 
                                            ConfirmDialogType="RadWindow" 
                                            ConfirmText="ลบข้อมูลที่เลือก?" 
                                            ItemStyle-Width="15" 
                                            Text="คลิกเพื่อลบรายการ" 
                                            UniqueName="column1">
                                            <ItemStyle HorizontalAlign="Center" />
                                            <HeaderStyle Width="15px"></HeaderStyle>
                                        </telerik:GridButtonColumn>
                                    <telerik:GridBoundColumn 
                                        DataField="user_seq" 
                                        DataType="System.Int32" 
                                        Display="False" 
                                        HeaderText="user_seq" 
                                        ReadOnly="True" 
                                        UniqueName="user_seq" >                                       
                                    </telerik:GridBoundColumn>                                    
                                    <telerik:GridBoundColumn Visible = "false"
                                        DataField="user_name" 
                                        FilterControlWidth = "100%"
                                        AutoPostBackOnFilter ="true"
                                        ShowFilterIcon ="false"
                                        HeaderText="user_name" 
                                        UniqueName="user_name">
                                        <HeaderStyle HorizontalAlign="Center" Width="100px" />
                                        <ItemStyle HorizontalAlign ="Left" Width = "100px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn
                                        DataField="user_code" 
                                        FilterControlWidth = "100%"
                                        AutoPostBackOnFilter ="true"
                                        ShowFilterIcon ="false"
                                        HeaderText="รหัสผู้ใช้งาน" 
                                        UniqueName="user_code">
                                        <HeaderStyle HorizontalAlign="Center" Width="100px" />
                                        <ItemStyle HorizontalAlign ="Left" Width = "100px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn 
                                            AutoPostBackOnFilter="true" 
                                            ShowFilterIcon="false" 
                                            CurrentFilterFunction="Contains" 
                                            DataField="user_name" 
                                            FilterControlWidth="100%" 
                                            HeaderStyle-HorizontalAlign="Center" 
                                            HeaderStyle-Width = "100px"
                                            HeaderText="ชื่อ - นามสกุล">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="cmdShowView" runat="server" CommandName = "ShowDetail"
                                                    Text='<%# Eval("user_name") %>'>                                                 
                                                </asp:LinkButton>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                    
                                    <telerik:GridBoundColumn 
                                        DataField="pos_name" 
                                        FilterControlWidth = "100%"
                                        AutoPostBackOnFilter ="true"
                                        ShowFilterIcon ="false"
                                        HeaderText="ตำแหน่ง" 
                                        UniqueName="pos_name">
                                        <HeaderStyle HorizontalAlign="Center" Width="150px" />
                                        <ItemStyle HorizontalAlign ="Left" Width = "150px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn 
                                        DataField="class_name" 
                                        FilterControlWidth = "100%"
                                        AutoPostBackOnFilter ="true"
                                        ShowFilterIcon ="false"
                                        HeaderText="ระดับ" 
                                        UniqueName="class_name">
                                        <HeaderStyle HorizontalAlign="Center" Width="100px" />
                                        <ItemStyle HorizontalAlign ="Left" Width = "100px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn 
                                        DataField="working_job_site_name" 
                                        FilterControlWidth = "100%"
                                        AutoPostBackOnFilter ="true"
                                        ShowFilterIcon ="false"
                                        HeaderText="สังกัดปฏิบัติ" 
                                        UniqueName="working_job_site_name">
                                        <HeaderStyle HorizontalAlign="Center" Width="150px" />
                                        <ItemStyle HorizontalAlign ="Left" Width = "150px" />
                                    </telerik:GridBoundColumn> 
                                    </Columns>
                                    <EditFormSettings EditFormType="WebUserControl" 
                                        UserControlName="../UserControls/Users.ascx">
                                        <EditColumn UniqueName="EditCommandColumn1">
                                        </EditColumn>
                                    </EditFormSettings>
                                    <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                                </MasterTableView>
                                <ClientSettings AllowColumnHide="True" 
                                    AllowColumnsReorder="True" 
                                    EnableRowHoverStyle="True" 
                                    ReorderColumnsOnClient="True">
                                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                                </ClientSettings>
                            </telerik:RadGrid>
                        </td>
                    </tr>
                    <tr>
                    <td>

                    </td>
                    </tr>
                </table>
            </asp:Panel>
            <asp:Panel ID="PanelUserRole" runat="server" Width="990px" ScrollBars="Auto">           
                <table align="center" width="890px">                    
                     <tr style="padding-top: 10px">
                        <td class="TextHeaderSmall" width="150px">
                            <asp:Label ID="lblUserRoll" runat="server" Text="สิทธิ์การใช้งานระบบของ " />
                        </td>
                        <td class="TextHeaderSmall" style="padding-top: 10px">
                            <asp:LinkButton ID = "cmdBackHome" runat ="server" ForeColor="#003399" 
                                    onclick="cmdBackHome_Click"></asp:LinkButton>
                            <asp:Label ID="lblUserSeq" runat="server" Visible = "False"/>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="TextHeaderSmall" style="padding-top: 10px">ระบบ :</td>
                        <td align="left" class="TextHeaderSmall" style="padding-top: 10px">
                            <asp:RadioButtonList ID="rblSystemID" runat="server" 
                                RepeatDirection="Horizontal" AutoPostBack="True" 
                                onselectedindexchanged="rblSystemID_SelectedIndexChanged" 
                                RepeatColumns="4" >
                                <asp:ListItem Text="บริหารงบประมาณ" Value="GBMS" Selected="True"></asp:ListItem>
                                <asp:ListItem Value="WEBGIMS">บริหารพัสดุ</asp:ListItem>
                                <%--<asp:ListItem Text="บริหารการพัสดุ" Value="GIMS" Enabled="False" ></asp:ListItem>--%>
                                <asp:ListItem Text="บริหารการเงิน" Value="GFMS" ></asp:ListItem>
                                <asp:ListItem Text="บริหารการบัญชี" Value="GAMS" ></asp:ListItem>
                                <asp:ListItem Text="บริหารทรัพยากรบุคคล" Value="GHRMS"></asp:ListItem>
                                <asp:ListItem Text="ESS" Value="ESS"></asp:ListItem>
                                <asp:ListItem Text="ควบคุมสิทธิ์" Value="ADMIN"></asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                    <tr>
                        <td colspan = "2" align="center"  style="padding-top: 10px">
                            <telerik:RadGrid ID="RadGrid2" runat="server" 
                                AllowAutomaticDeletes="True" 
                                AllowFilteringByColumn="True" AllowMultiRowEdit="True" 
                                AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True" 
                                AutoGenerateColumns="False" EnableAJAX="True" 
                                EnableAJAXLoadingTemplate="True" 
                                GridLines="None" 
                                OnItemCommand="RadGrid2_ItemCommand"  
                                onitemdatabound="RadGrid2_ItemDataBound"
                                Width="700px">
                                <MasterTableView AllowMultiColumnSorting="True" 
                                    CellSpacing="-1" 
                                    ClientDataKeyNames="role_seq" 
                                    CommandItemDisplay="Top" 
                                    DataKeyNames="role_seq" 
                                    InsertItemPageIndexAction="ShowItemOnCurrentPage"  
                                    EnableNoRecordsTemplate ="true"                                                                
                                    NoMasterRecordsText="&lt; ไม่มีสิทธิ์เข้าใช้งาน &gt;">
                                    <CommandItemTemplate>
                                        <table width="100%">
                                            <tr>
                                                <td>
                                                    <asp:LinkButton ID="cmdEditView" 
                                                    CommandName="EditView" runat="server"
                                                    Visible="<%# !RadGrid2.MasterTableView.IsItemInserted && RadGrid2.EditIndexes.Count <= 0 %>" 
                                                    CausesValidation="False" > 
                                                    <img alt="" src="../Images/Buttons/Edit.gif" 
                                                    style="border: 0px; vertical-align: middle;" /> แก้ไขสิทธิ์การใช้งาน </asp:LinkButton>
                                                <asp:LinkButton ID="cmdUpdateAll" runat="server" CausesValidation="False" 
                                                    CommandName="UpdateAll" Visible = "false" > 
                                                    <img style="border:0px;vertical-align:middle;" alt=""                                    
                                                    src="../Images/Buttons/saveDisk.gif" /> บันทึก</asp:LinkButton>
                                                <asp:LinkButton ID="cmdCancelAll" runat="server" CausesValidation="False" 
                                                    CommandName="CancelAll" Visible = "false" > 
                                                    <img style="border:0px;vertical-align:middle;" alt=""                                    
                                                    src="../Images/Buttons/Cancel.gif" /> ยกเลิก</asp:LinkButton>
                                                </td>
                                                <td align="right">
                                                </td>
                                            </tr>
                                        </table>
                                    </CommandItemTemplate>
                                    <RowIndicatorColumn>
                                        <HeaderStyle Width="20px" />
                                    </RowIndicatorColumn>
                                    <ExpandCollapseColumn>
                                        <HeaderStyle Width="20px" />
                                    </ExpandCollapseColumn>
                                    <Columns>
                                        <telerik:GridEditCommandColumn  Visible="False"
                                            ButtonType="ImageButton" 
                                            EditText="คลิกเพื่อแก้ไขรายการ" 
                                        FilterControlWidth = "100%"
                                            ItemStyle-Width="15">
                                            <HeaderStyle Width="24px"></HeaderStyle>
                                            <ItemStyle HorizontalAlign="Center" />
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridButtonColumn 
                                            ButtonType="ImageButton" 
                                            CommandName="Delete" 
                                            ConfirmDialogType="RadWindow" 
                                            ConfirmText="ลบข้อมูลที่เลือก?" 
                                            ItemStyle-Width="15" 
                                            Text="คลิกเพื่อลบรายการ" 
                                            UniqueName="column1">
                                            <HeaderStyle Width="24px"></HeaderStyle>
                                            <ItemStyle HorizontalAlign="Center" />
                                        </telerik:GridButtonColumn>
                                        <telerik:GridBoundColumn 
                                        DataField="role_seq" 
                                        DataType="System.Int32"  
                                        Visible = "false"
                                        HeaderText="role_seq" 
                                        ReadOnly="True" 
                                        UniqueName="role_seq" >
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn Visible = "false"
                                        DataField="user_role_seq" 
                                        FilterControlWidth = "100%"
                                        AutoPostBackOnFilter ="true"
                                        ShowFilterIcon ="false"
                                        HeaderText="user_role_seq" 
                                        UniqueName="user_role_seq">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn Visible = "false"
                                        DataField="has_role" 
                                        FilterControlWidth = "100%"
                                        AutoPostBackOnFilter ="true"
                                        ShowFilterIcon ="false"
                                        UniqueName="has_role"> 
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn 
                                        HeaderStyle-HorizontalAlign = "Center" 
                                        ItemStyle-HorizontalAlign = "Center"
                                        ShowFilterIcon="false"  
                                        DataField="has_role" AllowFiltering="False"
                                        HeaderText="มีสิทธิใช้งาน">
                                        <ItemTemplate>       
                                            <asp:CheckBox ID = "chkHasRole" runat = "server" />
                                            <asp:Image runat="server" ID="imgHasRole" 
                                                ImageUrl='<%# GetTrueFalseImage(DataBinder.Eval(Container, "DataItem.has_role").ToString()
					                                        , "1", "0", "../Images/Buttons/Update.gif", "../Images/Buttons/Cancel.gif")  %>' />                                   
                                        </ItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" Width="80px" /> 
                                        <ItemStyle HorizontalAlign="Center" Width="80px" /> 
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn
                                        DataField="role_name" 
                                        FilterControlWidth = "100%"
                                        AutoPostBackOnFilter ="true"
                                        ShowFilterIcon ="false"
                                        HeaderText="ชื่อสิทธิในการใช้งาน" 
                                        UniqueName="role_name">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign ="Left" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn
                                        DataField="system_id" 
                                        FilterControlWidth = "100%"
                                        AutoPostBackOnFilter ="true"
                                        ShowFilterIcon ="false"
                                        HeaderText="ระบบ" 
                                        UniqueName="system_id">
                                        <HeaderStyle HorizontalAlign="Center" Width="150px" />
                                        <ItemStyle HorizontalAlign ="Left" Width = "150px" />
                                    </telerik:GridBoundColumn>
                                     
                                    </Columns>
                                    <EditFormSettings EditFormType="WebUserControl" 
                                        UserControlName="../UserControls/Users.ascx">
                                        <EditColumn UniqueName="EditCommandColumn1">
                                        </EditColumn>
                                    </EditFormSettings>
                                    <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                                </MasterTableView>
                                <ClientSettings AllowColumnHide="True" 
                                    AllowColumnsReorder="True" 
                                    EnableRowHoverStyle="True" 
                                    ReorderColumnsOnClient="True">
                                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                                </ClientSettings>
                            </telerik:RadGrid>
                        </td>
                    </tr>
                </table>
            </asp:Panel> 
        </div>
    </div>    

</asp:Content>


